import json
import sys
import requests

from PyQt5.QtWidgets import QWidget, QApplication

import yuanye
from main_view import MainView
from ui.form_login import Ui_Form

url = 'http://127.0.0.1:8088/login'


class LoginView(QWidget, Ui_Form):

    def __init__(self):
        super(LoginView, self).__init__()
        self.setupUi(self)

    def login(self):
        cid = self.lineEdit.text()
        password = self.lineEdit_2.text()
        r = yuanye.login(cid, password)
        # r = yuanye.login('1234', '123')
        if r[0]:
            print(r)
            self.mainview = MainView(r[1])
            self.mainview.show()
            self.close()
        else:
            print(r[1])


if __name__ == '__main__':
    app = QApplication(sys.argv)
    login = LoginView()
    login.show()
    sys.exit(app.exec_())